/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package scubalogbook.data;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class Sqlite {

    Connection conn;
    Statement stat;
    
    public Sqlite(String dbPath) throws Exception 
    {    
      Class.forName("org.sqlite.JDBC");            
      conn = DriverManager.getConnection("jdbc:sqlite:" + dbPath);
      stat = conn.createStatement();
      
      Properties properties = new Properties();
      properties.setProperty(scubalogbook.ScubaLogbookView.PROPERTY_LAST_OPENED_DB_FILE, dbPath);    
      try {
        properties.store(new FileOutputStream(scubalogbook.ScubaLogbookView.CONFIG_FILE), "ScubaLogbook properties");
      } catch (FileNotFoundException e) {
        Logger logger = Logger.getLogger("scubaLogbook");  
        logger.log(Level.SEVERE, "failed to store properties", e);          
      } catch (IOException e) {
        Logger logger = Logger.getLogger("scubaLogbook");  
        logger.log(Level.SEVERE, "failed to store properties", e);  
      }      
    }
    
    
//    public DiveList GetAllDives() throws Exception
//    {   
//        DiveList diveList = null;
//        
//        ResultSet rsCount = stat.executeQuery("SELECT COUNT(*) AS rowcount FROM Dive");
//        rsCount.next();
//        int totalRows = rsCount.getInt("rowcount") ;
//        rsCount.close() ;
//
//        if (totalRows > 0)
//        {        
//            ResultSet rs = stat.executeQuery("select * from Dive;");
//            Object[][] listOfDives = new Object[totalRows][5];            
//
//            String[] columnNames = new String[5];
//            columnNames[0] = "id";
//            columnNames[1] = "Dive start";
//            columnNames[2] = "Duration";
//            columnNames[3] = "Max. Depth";
//            columnNames[4] = "Base";
//
//            int rowNumber = 0;            
//            while (rs.next()) {
//                listOfDives[rowNumber][0] = rs.getInt("id");
//                listOfDives[rowNumber][1] = rs.getDate("diveStart");
//                listOfDives[rowNumber][2] = rs.getInt("duration");
//                listOfDives[rowNumber][3] = rs.getDouble("depthMax");
//                listOfDives[rowNumber][4] = rs.getInt("baseID");                
//                rowNumber++;
//            }
//
//            diveList = new DiveList(listOfDives, columnNames);            
//            rs.close();
//        }
//        
//        return diveList;
//    }
       
    public void CloseConnection() throws Exception
    {
        conn.close();
    }
    
    public void CreateNewProfile() throws Exception
    {        
        CreateBaseTable();
        CreateBuddyTable();
        CreateCountryTable();
        CreateDiveActivityTable();
        CreateDiveTypeTable();
        CreateDiveTable(); 
        CreateEquipmentTable();
        CreateEquipmentSetTable();
        CreateEquipmentToSetConnectionTable();
        CreateEquipmentTypeTable();        
        CreatePictureTable();
        CreatePictureGalleryTable();        
    }

    private void CreateBaseTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `Base`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `Base` (`id` INTEGER DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '', `countryID` INTEGER DEFAULT '');");
    }
            
    private void CreateBuddyTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `Buddy`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `Buddy` (`id` INTEGER PRIMARY KEY  DEFAULT '', `name` VARCHAR DEFAULT '', `surname` VARCHAR DEFAULT '');");
    }
    
    private void CreateCountryTable() throws Exception
    {                
        // Drop table
        stat.executeUpdate("drop table if exists `Country`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `Country` (`id` INTEGER PRIMARY KEY  DEFAULT '',`title` VARCHAR DEFAULT '', `flag` BLOB DEFAULT'');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (1, 'Afghanistan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (2, 'Åland Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (3, 'Albania');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (4, 'Algeria');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (5, 'American Samoa');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (6, 'Andorra');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (7, 'Angola');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (8, 'Anguilla');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (9, 'Antarctica');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (10, 'Antigua and Barbuda');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (11, 'Argentina');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (12, 'Armenia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (13, 'Aruba');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (14, 'Australia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (15, 'Austria');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (16, 'Azerbaijan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (17, 'Bahamas');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (18, 'Bahrain');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (19, 'Bangladesh');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (20, 'Barbados');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (21, 'Belarus');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (22, 'Belgium');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (23, 'Belize');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (24, 'Benin');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (25, 'Bermuda');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (26, 'Bhutan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (27, 'Bolivia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (28, 'Bosnia and Herzegovina');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (29, 'Botswana');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (30, 'Bouvet Island');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (31, 'Brazil');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (32, 'British Indian Ocean territory');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (33, 'Brunei Darussalam');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (34, 'Bulgaria');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (35, 'Burkina Faso');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (36, 'Burundi');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (37, 'Cambodia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (38, 'Cameroon');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (39, 'Canada');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (40, 'Cape Verde');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (41, 'Cayman Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (42, 'Central African Republic');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (43, 'Chad');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (44, 'Chile');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (45, 'China');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (46, 'Christmas Island');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (47, 'Cocos (Keeling) Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (48, 'Colombia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (49, 'Comoros');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (50, 'Congo');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (51, 'Congo Democratic Republic');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (53, 'Cook Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (54, 'Costa Rica');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (55, 'CÔte Ivoire (Ivory Coast)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (56, 'Croatia (Hrvatska)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (57, 'Cuba');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (58, 'Cyprus');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (59, 'Czech Republic');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (60, 'Denmark');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (61, 'Djibouti');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (62, 'Dominica');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (63, 'Dominican Republic');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (64, 'East Timor');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (65, 'Ecuador');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (66, 'Egypt');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (67, 'El Salvador');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (68, 'Equatorial Guinea');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (69, 'Eritrea');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (70, 'Estonia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (71, 'Ethiopia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (72, 'Falkland Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (73, 'Faroe Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (74, 'Fiji');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (75, 'Finland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (76, 'France');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (77, 'French Guiana');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (78, 'French Polynesia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (79, 'French Southern Territories');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (80, 'Gabon');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (81, 'Gambia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (82, 'Georgia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (83, 'Germany');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (84, 'Ghana');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (85, 'Gibraltar');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (86, 'Greece');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (87, 'Greenland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (88, 'Grenada');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (89, 'Guadeloupe');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (90, 'Guam');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (91, 'Guatemala');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (92, 'Guinea');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (93, 'Guinea-Bissau');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (94, 'Guyana');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (95, 'Haiti');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (96, 'Heard and McDonald Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (97, 'Honduras');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (98, 'Hong Kong');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (99, 'Hungary');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (100, 'Iceland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (101, 'India');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (102, 'Indonesia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (103, 'Iran');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (104, 'Iraq');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (105, 'Ireland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (106, 'Israel');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (107, 'Italy');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (108, 'Jamaica');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (109, 'Japan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (110, 'Jordan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (111, 'Kazakhstan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (112, 'Kenya');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (113, 'Kiribati');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (114, 'Korea (north)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (115, 'Korea (south)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (116, 'Kuwait');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (117, 'Kyrgyzstan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (118, 'Lao Peoples Democratic Republic');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (119, 'Latvia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (120, 'Lebanon');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (121, 'Lesotho');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (122, 'Liberia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (123, 'Libyan Arab Jamahiriya');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (124, 'Liechtenstein');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (125, 'Lithuania');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (126, 'Luxembourg');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (127, 'Macao');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (128, 'Macedonia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (129, 'Madagascar');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (130, 'Malawi');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (131, 'Malaysia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (132, 'Maldives');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (133, 'Mali');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (134, 'Malta');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (135, 'Marshall Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (136, 'Martinique');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (137, 'Mauritania');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (138, 'Mauritius');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (139, 'Mayotte');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (140, 'Mexico');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (141, 'Micronesia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (142, 'Moldova');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (143, 'Monaco');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (144, 'Mongolia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (145, 'Montserrat');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (146, 'Morocco');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (147, 'Mozambique');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (148, 'Myanmar');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (149, 'Namibia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (150, 'Nauru');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (151, 'Nepal');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (152, 'Netherlands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (153, 'Netherlands Antilles');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (154, 'New Caledonia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (155, 'New Zealand');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (156, 'Nicaragua');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (157, 'Niger');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (158, 'Nigeria');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (159, 'Niue');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (160, 'Norfolk Island');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (161, 'Northern Mariana Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (162, 'Norway');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (163, 'Oman');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (164, 'Pakistan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (165, 'Palau');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (166, 'Palestinian Territories');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (167, 'Panama');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (168, 'Papua New Guinea');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (169, 'Paraguay');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (170, 'Peru');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (171, 'Philippines');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (172, 'Pitcairn');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (173, 'Poland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (174, 'Portugal');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (175, 'Puerto Rico');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (176, 'Qatar');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (177, 'RÉunion');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (178, 'Romania');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (179, 'Russian Federation');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (180, 'Rwanda');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (181, 'Saint Helena');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (182, 'Saint Kitts and Nevis');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (183, 'Saint Lucia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (184, 'Saint Pierre and Miquelon');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (185, 'Saint Vincent and the Grenadines');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (186, 'Samoa');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (187, 'San Marino');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (188, 'Sao Tome and Principe');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (189, 'Saudi Arabia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (190, 'Senegal');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (191, 'Serbia and Montenegro');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (192, 'Seychelles');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (193, 'Sierra Leone');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (194, 'Singapore');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (195, 'Slovakia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (196, 'Slovenia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (197, 'Solomon Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (198, 'Somalia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (199, 'South Africa');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (200, 'South Georgia and the South Sandwich Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (201, 'Spain');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (202, 'Sri Lanka');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (203, 'Sudan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (204, 'Suriname');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (205, 'Svalbard and Jan Mayen Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (206, 'Swaziland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (207, 'Sweden');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (208, 'Switzerland');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (209, 'Syria');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (210, 'Taiwan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (211, 'Tajikistan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (212, 'Tanzania');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (213, 'Thailand');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (214, 'Togo');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (215, 'Tokelau');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (216, 'Tonga');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (217, 'Trinidad and Tobago');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (218, 'Tunisia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (219, 'Turkey');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (220, 'Turkmenistan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (221, 'Turks and Caicos Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (222, 'Tuvalu');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (223, 'Uganda');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (224, 'Ukraine');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (225, 'United Arab Emirates');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (226, 'United Kingdom');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (227, 'United States of America');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (228, 'Uruguay');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (229, 'Uzbekistan');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (230, 'Vanuatu');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (231, 'Vatican City');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (232, 'Venezuela');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (233, 'Vietnam');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (234, 'Virgin Islands (British)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (235, 'Virgin Islands (US)');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (236, 'Wallis and Futuna Islands');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (237, 'Western Sahara');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (238, 'Yemen');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (239, 'Zaire');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (240, 'Zambia');");
        stat.executeUpdate("INSERT INTO `Country` VALUES (241, 'Zimbabwe');");
    }
    
    private void CreateDiveActivityTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `DiveActivity`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `DiveActivity` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '');");
    }
    
    private void CreateDiveTypeTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `DiveType`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `DiveType` (`id` VARCHAR DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '');");
    }
    
    private void CreateDiveTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `Dive`;");
        // Create table
        stat.executeUpdate("CREATE  TABLE `Dive` (`id` INTEGER PRIMARY KEY  DEFAULT '', `diveStart` DATETIME DEFAULT '', `duration` DOUBLE DEFAULT '', `baseID` INTEGER DEFAULT '', `depthMax` DOUBLE DEFAULT '', `depthAverage` DOUBLE DEFAULT '', `visibility` DOUBLE DEFAULT '', `temperatureWater` DOUBLE DEFAULT '', `temperatureSurface` DOUBLE DEFAULT '', `buddyID` INTEGER DEFAULT '', `diveTypeID` INTEGER DEFAULT '', `diveActivityID` INTEGER DEFAULT '', `equipmentSetID` INTEGER DEFAULT '', `description` VARCHAR DEFAULT '', `picuteGalleryID` INTEGER DEFAULT '');");        
    }
    
    private void CreateEquipmentTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `Equipment`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `Equipment` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '', `equipmentTypeID` INTEGER DEFAULT '');");
    }
    
    private void CreateEquipmentSetTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `EquipmentSet`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `EquipmentSet` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '');");
    }
    
    private void CreateEquipmentToSetConnectionTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `EquipmentToSetConnection`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `EquipmentToSetConnection` (`id` INTEGER PRIMARY KEY  DEFAULT '', `equipmentID` INTEGER NOT NULL  DEFAULT '', `equipmentSetID` INTEGER NOT NULL  DEFAULT '');");
    }
    
    private void CreateEquipmentTypeTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `EquipmentType`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `EquipmentType` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` VARCHAR DEFAULT '', `description` VARCHAR DEFAULT '');");
    }
                                      
    private void CreatePictureTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `Picture`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `Picture` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` VARCHAR DEFAULT '', `filePath` VARCHAR DEFAULT '');");
    }        
    
    private void CreatePictureGalleryTable() throws Exception
    {
        // Drop table
        stat.executeUpdate("drop table if exists `PictureGallery`;");
        // Create table
        stat.executeUpdate("CREATE TABLE `PictureGallery` (`id` INTEGER PRIMARY KEY  DEFAULT '', `title` INTEGER DEFAULT '', `description` VARCHAR DEFAULT '');");
    }    
}
